package com.xiaobaibai.bo;

import java.util.Date;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class OrderDelayItem implements Delayed {

    private String orderId;

    private Date expiredTime;

    public OrderDelayItem(String orderId, Date expiredTime) {
        this.orderId = orderId;
        this.expiredTime = expiredTime;
    }

    @Override
    public long getDelay(TimeUnit unit) {
        return unit.convert(this.getExpiredTime().getTime()-System.currentTimeMillis(),TimeUnit.MILLISECONDS);
    }

    @Override
    public int compareTo(Delayed o) {
        return this.getExpiredTime().compareTo(((OrderDelayItem)o).getExpiredTime());
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public Date getExpiredTime() {
        return expiredTime;
    }

    public void setExpiredTime(Date expiredTime) {
        this.expiredTime = expiredTime;
    }

}
